# ifndef DEF_RENDERER
# define DEF_RENDERER

# include "Source.h"

# include "Module.h"

/**
*	This class renders the scene, creates the window and calls the main class: Game.
*/

class Renderer : public Module, public Ogre::FrameListener, public Ogre::WindowEventListener
{
	public:

	Renderer( Game*);
	~Renderer();

	Ogre::RenderWindow* getWindow(); 
	Ogre::SceneManager* getSceneManager();

	bool init( GUI*, AI*, EventListener*);

	void start();

	Ogre::SceneNode* createSceneNode( const Ogre::String&);
	Ogre::Entity* createEntity( const Ogre::String&, const Ogre::String&);
	Ogre::Camera* createCamera( const Ogre::String&);
	Ogre::Viewport* createViewport( Ogre::Camera*);

	void deleteEntity( Ogre::Entity*);
	void deleteSceneNode( Ogre::SceneNode*);
	void deleteCamera( Ogre::Camera*);
	void deleteViewport( Ogre::Viewport*);

	protected:

	virtual bool frameRenderingQueued( const Ogre::FrameEvent&);

	virtual void windowResized( Ogre::RenderWindow*); 

	private:

	virtual void handleEvents();

	void setupResources();
	bool setupConfig();
	void initSceneManager();
	void initCamera();
	void initViewport();
	void initFrameListener();
	void createScene();
	
	bool myShutDown;

	Ogre::Root* myRoot;
	Ogre::RenderWindow* myWindow;
	Ogre::SceneManager* mySceneManager;
	Ogre::Camera* myCamera;

	GUI* myGUI;
	AI* myAI;
	EventListener* myEventListener;
};

# endif